<template>
  <div class="layout">
    <div class="layout-content">
      <header-box></header-box>
      <div class="width-percent-100 content-box flex-par">

        <el-menu class="contentLeft" :default-active="$store.state.activePath" :router="true">
          <div class="sidebar-header">
            <div class="sidebar-title">
              <i class="sidebar-icon">👨‍💻</i>
              <span>开发者中心</span>
            </div>
          </div>
          <el-menu-item class="active-style" index="/kaifaIndex">
            <i class="menu-icon">📊</i>
            <span>概览</span>
          </el-menu-item>
          <el-menu-item class="active-style" index="/kaifaForm">
            <i class="menu-icon">📤</i>
            <span>上传应用</span>
          </el-menu-item>
          <el-menu-item class="active-style" index="/accountList">
            <i class="menu-icon">🔐</i>
            <span>账号与安全</span>
          </el-menu-item>
          <el-menu-item v-if="$store.state.isAdmin" class="active-style" index="/scenarioList">
            <i class="menu-icon">⚙️</i>
            <span>应用场景管理</span>
          </el-menu-item>
        </el-menu>
        <div class="yingyong-page">
          <router-view></router-view>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
// import // boundEmpSys,
// '@/assets/api/api.js';

import headerBox from '@/components/headerBox';


import { bizTypeMenu, getKaifaData, getSelectByType, pageSize } from '@/assets/api/api.js';
import { mapMutations } from 'vuex';
import { RouterView } from 'vue-router';
export default {
  data: function () {
    return {
      radioV: '',
      typeMenuList: [],
      typeId: '-1',
      tableData: [],
      dataTotal: 0,
      searchForm: {
        bizType: '',
        subBizType: '',
        pageNum: 1,
        pageSize,
      },
      kaifaData: {}
    }
  },
  components: {
    headerBox
  },
  mounted() {
    this.getKaifaDataF()
    this.getBizTypes()
    this.getPageList(1)
    this.getUserInfo()
  },
  methods: {
    ...mapMutations(['setUserInfo']),
    toDetail(id) {
      this.$router.push({ path: '/kaifaForm', query: { id } });

    },
    //   -列表
    getPageList(pageNum) {
      if (pageNum) {
        this.searchForm.pageNum = pageNum
      }
      this.searchForm.bizType = this.typeId == '-1' ? '' : this.typeId
      getSelectByType(this.searchForm)
        .then((res) => {
          console.log(res)
          if (res.code == 0) {
            //console.log(res.data)
            this.tableData = res.data
            this.dataTotal = res.total
          }
        })
        .catch((err) => { });
    },
    changeType(v, v2) {
      console.log(v)
      console.log(v2)
      this.typeId = v
      this.getPageList(1)
    },
    // toHome() {
    //   this.$router.push({ path: '/' });
    // },
    // handleClose(e) {
    //   //console.log(e);
    // },
    // gotoMap() {
    //   // window.location.href = 'index.html'
    //   window.location.href = `http://${window.location.hostname}`;
    // },
    getBizTypes() {
      bizTypeMenu()
        .then((res) => {
          console.log(res)
          if (res.code == 0) {
            this.typeMenuList = res.data.children
          }
        })
        .catch((err) => { });
    },
    getKaifaDataF() {
      getKaifaData()
        .then((res) => {
          console.log(res)
          if (res.code == 0) {
            this.kaifaData = res.data
            // 同时设置用户信息到store
            this.setUserInfo(res.data)
          }
        })
        .catch((err) => { });
    },
    // 获取用户信息
    getUserInfo() {
      getKaifaData()
        .then((res) => {
          console.log('用户信息:', res)
          if (res.code == 0) {
            this.setUserInfo(res.data)
          }
        })
        .catch((err) => { 
          console.error('获取用户信息失败:', err)
        });
    },
  },
};
</script>
<style scoped>
.layout {
  height: 100%;
}

.layout-content {
  height: 100%;
  width: 100%;
  background: white;
  /* background-size: 100% 100%; */
}

.content-box {
  height: calc(100% - 70px);
  width: 100%;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  position: relative;
  overflow: hidden;
}

.content-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.1) 0%, transparent 50%),
              radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
  pointer-events: none;
}

.contentLeft {
  width: 280px;
  background: linear-gradient(180deg, rgba(0, 21, 42, 0.95) 0%, rgba(0, 21, 42, 0.9) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  z-index: 10;
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
}

.contentLeft::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 20%, rgba(53, 107, 226, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(0, 242, 241, 0.1) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

.contentLeft::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(180deg, 
    rgba(53, 107, 226, 0.8) 0%, 
    rgba(0, 242, 241, 0.8) 50%, 
    rgba(53, 107, 226, 0.8) 100%);
  box-shadow: 0 0 10px rgba(53, 107, 226, 0.5);
}

.sidebar-header {
  padding: 20px 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 10px;
}

.sidebar-title {
  display: flex;
  align-items: center;
  color: white;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 1px;
}

.sidebar-icon {
  font-size: 24px;
  margin-right: 12px;
  filter: drop-shadow(0 0 8px rgba(53, 107, 226, 0.5));
}

.menu-icon {
  font-size: 18px;
  margin-right: 12px;
  transition: all 0.3s ease;
}

.el-sub-menu /deep/ .el-menu {
  background-color: rgba(0, 21, 42, 1);
}

.contentLeft .el-sub-menu .el-menu li {
  width: 100%;
  box-sizing: inherit;
  background: rgba(0, 21, 42, 1);
}

.contentLeft /deep/ .el-menu-item,
.contentLeft /deep/ .el-sub-menu__title {
  height: 50px;
  line-height: 50px;
  color: white;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 500;
  margin: 8px 15px;
  padding: 0 20px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  width: calc(100% - 30px);
  box-sizing: border-box;
}

.contentLeft /deep/ .el-menu-item::before,
.contentLeft /deep/ .el-sub-menu__title::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.5s;
}

.contentLeft /deep/ .el-menu-item:hover::before,
.contentLeft /deep/ .el-sub-menu__title:hover::before {
  left: 100%;
}


.contentLeft /deep/ .el-sub-menu__title:hover {
  background: linear-gradient(135deg, rgba(53, 107, 226, 0.8), rgba(0, 242, 241, 0.8)) !important;
  border-radius: 12px;
  transform: translateX(3px);
  box-shadow: 0 6px 20px rgba(53, 107, 226, 0.4);
}

.contentLeft /deep/ .el-menu-item:hover {
  background: linear-gradient(135deg, rgba(53, 107, 226, 0.8), rgba(0, 242, 241, 0.8)) !important;
  border-radius: 12px;
  transform: translateX(3px);
  box-shadow: 0 6px 20px rgba(53, 107, 226, 0.4);
}

.contentLeft /deep/ .el-menu-item:hover .menu-icon {
  transform: scale(1.2) rotate(5deg);
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.8));
}

.contentLeft /deep/ .el-menu-item.is-active {
  background: linear-gradient(135deg, rgba(53, 107, 226, 1), rgba(0, 242, 241, 1)) !important;
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(53, 107, 226, 0.5);
  transform: translateX(2px);
}

.contentLeft /deep/ .el-menu-item.is-active .menu-icon {
  transform: scale(1.1);
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 1));
}

.yingyong-page {
  height: 100%;
  flex: 1;
  overflow: auto;
  background: linear-gradient(135deg, rgba(241, 249, 254, 0.8) 0%, rgba(195, 207, 226, 0.3) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: relative;
  z-index: 5;
}

.page-title-box {
  height: 60px;
  line-height: 60px;
  color: #00152A;
  font-size: 18px;
  font-weight: 600;
  background-color: white;
}

.title-icon {
  height: 35px;
  margin: 12.5px 5px 0 10px;
}


.list-content {
  height: calc(100% - 70px);
  overflow: auto;
}


.list-box {
  padding-left: 10px;
  padding-top: 10px;
  overflow: hidden;
}

.list-item-box {
  box-shadow: 0px 0px 3px rgba(191, 203, 199, 1);
  border-radius: 15px;
  margin-bottom: 10px;
  padding: 10px;
  margin-right: 10px;
  width: calc(25% - 10px);
  float: left;
  background: white;
}

.list-item-head {
  line-height: 50px;
}

.head-icon {
  height: 50px;
  width: 50px;
}

.head-txt {
  font-weight: 700;
  font-style: normal;
  font-size: 18px;
  color: #003C7E;
  margin-left: 6px;
}

.list-item-detail {
  color: #333333;
  font-size: 14px;
  margin: 10px 0;
  line-height: 24px;
  height: 72px;
}

.list-item-action {
  border-top: 1px #aaa dashed;
  padding-top: 10px;
}

.list-btn {
  font-size: 15px;
  height: 28px;
  line-height: 28px;
  border-radius: 14px;
  padding: 0 10px;
}

.white-btn {
  border: 1px solid rgba(215, 215, 215, 1);
}

.blue-btn {
  background: rgba(53, 107, 226, 1);
  border: 1px solid rgba(53, 107, 226, 1);
  color: white;
}

.list-btn-icon {
  height: 16px;
  margin-top: 6px;
  margin-right: 2px;
}

.page-info-box {
  background: rgba(242, 242, 242, .6);
  margin: 20px;
  border-radius: 10px;
  padding: 20px;
}

.info-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin-right: 16px;
  background: #436ADB;
  text-align: center;
  line-height: 80px;
  font-size: 40px;
  color: white;
}

.info-name {
  font-size: 24px;
  font-weight: 600;
  color: black;
  letter-spacing: 3px;
}

.page-info-box .list-item-action {
  border-top: none;
}

.info-item {
  height: 80px;
  border: 1px solid rgba(47, 90, 201, 1);
  border-radius: 10px;
  margin-left: 20px;
  padding: 10px 25px;
}

.white-info {
  background-color: white;
}

.blue-info {
  background-color: rgba(53, 107, 226, 1);
  color: white;
}

.info-icon {
  height: 44px;
  width: 44px;
  margin-right: 10px;
  margin-top: 9px;
}

.info-txt {
  font-size: 18px;
  color: #000;
  font-weight: 700;
}

.info-num {
  font-size: 14px;
}

.num-txt {
  font-size: 24px;
  font-weight: 600;
  margin-right: 4px;
  color: #2F5AC9;
}

.blue-info .info-txt {
  color: white;
}

.blue-info .num-txt {
  color: #F59A23;
}
</style>